<?php

use App\Admin\Field\IntervalWeekNum;
use App\Admin\Field\VaccineIntervalWeekNum;
use App\Admin\Field\HospitalAppointMonthField;
use App\Models\Hospital;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Layout\Navbar;
use Dcat\Admin\Show;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Form::extend('intervalweeknum', VaccineIntervalWeekNum::class);

Form::extend('month', HospitalAppointMonthField::class);
Admin::navbar(function (Navbar $navbar) {
    $adminUser = Admin::user();
    if($adminUser){
        $hospital_id = $adminUser->hospital_id;
        $hospital = Hospital::query()->where('id',$hospital_id)->first();
        $hospitals = $adminUser->hospitals;

        $navbar->right(view('admin.head_select_hospital',['hospital'=>$hospital,'hospitals'=>$hospitals]));

    }
});
Grid::resolving(function (Grid $grid) {
    $grid->model()->orderBy('id', 'desc');
});
